package com.aaa.gs.controller;

import com.aaa.common.entity.Order;
import com.aaa.gs.po.Product;
import com.aaa.gs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @fileName:ProductController
 * @description:
 * @author:忆尘
 * @createTime:2020/11/3 17:07
 * @version:1.0.0
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @RequestMapping("/selectAll")
    public Map selectAll(){
        Map map = new HashMap();
        List<Product> products = productService.selectAll();
        List<Order> orders = productService.selectOrders();
        map.put("products",products);
        map.put("orders",orders);
        return map;
    }

    public Product selectById(Long id){
        return productService.selectByPrimaryKey(id);
    }
}
